// 2. Controller类
package com.ruoyi.teaching.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.teaching.dto.TeachingDesignRequest;
import com.ruoyi.teaching.service.TeachingDesignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@RestController
@Anonymous
@RequestMapping("/teaching")
public class TeachingDesignApiController {

    @Autowired
    private TeachingDesignService teachingDesignService;

    /**
     * 生成教学设计（教师用）
     */
    @PostMapping(value = "/generate", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public SseEmitter generateTeachingDesign(@RequestBody TeachingDesignRequest request) {
        return teachingDesignService.generateTeachingDesign(
            request.getSubject(),
            request.getTeacherId(),
            request.getClassId(),
            request.getTitle()
        );
    }

    /**
     * 获取教学设计详情
     */
    @GetMapping("/detail/{id}")
    public AjaxResult getTeachingDesignDetail(@PathVariable Long id) {
        return AjaxResult.success(teachingDesignService.getTeachingDesignDetail(id));
    }
}
